import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from "../views/Login";
import Blogs from "../views/Blogs";
import BlogEdit from "../views/BlogEdit";
import BlogDetail from "../views/BlogDetail";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Index',
    redirect: {name: 'Login'}
  },

    {
        path: '/blog/blogs',
        name: 'Blogs',
        component: Blogs
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },

    {
        path: '/blog/add',
        name: 'BlogAdd',
        component: BlogEdit,
        meta: {
            requireAuth: true
        }
    },
    {
        path: '/blog/:blogId',
        name: 'BlogDetail',
        component: BlogDetail,
        meta: {
            requireAuth: true
        }
    },
    {
        path: '/blog/:blogId/edit',
        name: 'BlogEdit',
        component: BlogEdit,
        meta: {
            requireAuth: true
        }
    },

];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BABEL_ENV,
    routes
});

export default router
